<template>
	<view>
		<dsl-navbar title="分享" isBack bgTopImg="" backBg='white' textTitle='white'></dsl-navbar>
		<view class="share_body text-center">
			<view class="text-lg text-bold padding-top">我的分享二维码</view>
			<view class=" text-sm padding-top">告诉你的小伙伴你正在使用源工云</view>
			<view style="width: 90%;height: 2rpx;border: 3rpx dashed #E1DFE0;" class="margin"></view>
			<image :src="'http://'+codeImage" mode="" class="share_image"></image>
		</view>

		<view class="share_bottom animation-slide-bottom">
			<view class="padding text-center text-lg">
				更多分享方式
			</view>
			<view class="flex rowsb padding text-center ">
				<view v-for="(item,index) in shareList" :key='index' @click="shareSubmit(index)">
					<image :src="item.icon" mode="" class="share_icon"></image>
					<view class="share_title">{{item.title}}</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		QRcode
	} from '@/common/path.js'
	export default {
		data() {
			return {
				shareList: [{
						title: '朋友圈',
						icon: '/static/user/share/imgpengyouquan-1.png'
					},
					{
						title: '好友',
						icon: '/static/user/share/imghaoyou.png'
					},
					{
						title: '抖音',
						icon: '/static/user/share/imgdouyin.png'
					},
					{
						title: '快手',
						icon: '/static/user/share/imgkuaishou.png'
					},
					{
						title: '海报',
						icon: '/static/user/share/imgxiazai.png'
					}
				],
				shareNum: 0,
				codeImage: '', //生成的二维码
				num:0,//分享类型 0企业 1员工
			}
		},
		onLoad(option) {
			// let url = 'http://47.100.222.48:1001/h5?id=181&amp;num=0'
			// console.log('[url]',url.split('num=')[1]);
			
			
			
			if(option.num){
				this.num = option.num
			}
		},
		onShow() {
			this.QRcode() //二维码
		},
		methods: {
			//二维码
			QRcode() {
				let data = {
					url: "http://47.100.222.48:1001/h5",
					id: uni.getStorageSync('userInfo').id,
					num:this.num
				}
				this.Http.POST(QRcode, data).then(res => {
					if (res.code == 1) {
						console.log('[二维码]', res.data);
						this.codeImage = res.data
					}
				})
			},

			//分享
			shareSubmit(i) {
				let url = 'http://'+this.codeImage
				if (i == 0) {
					uni.share({
						provider: "weixin",
						scene: "WXSceneTimeline",
						type: 0,
						href: "http://47.100.222.48:1001/h5", //分享链接
						title: "源工云",
						summary: "我正在使用源工云APP，赶紧跟我一起来体验！",
						imageUrl: url, //图片
						success: function(res) {
							console.log("success:" + JSON.stringify(res));
						},
						fail: function(err) {
							console.log("fail:" + JSON.stringify(err));
						}
					});
				} else {
					this.$tools.showToast('等待APP功能完成进行该功能部署')
				}
			}
		}
	}
</script>

<style lang="scss">
	page {
		background: #00D88F;
	}

	.share_body {
		width: 609rpx;
		height: 745rpx;
		background: #FFFFFF;
		opacity: 1;
		border-radius: 20rpx;
		margin: 0 auto;
		margin-top: 80rpx;
	}

	.share_image {
		width: 463rpx;
		height: 463rpx;
		opacity: 1;
		border-radius: 6rpx;
	}

	.share_icon {
		width: 76rpx;
		height: 76rpx;
		border-radius: 50%;
		opacity: 1;
	}

	.share_title {
		font-size: 24rpx;
		font-family: PingFang SC;
		font-weight: 400;
		color: #333333;
		opacity: 1;
	}

	.share_bottom {
		width: 750rpx;
		height: 334rpx;
		background: #FFFFFF;
		opacity: 1;
		border-radius: 31rpx 31rpx 0rpx 0rpx;
		position: fixed;
		bottom: 0;
	}
</style>
